var mySwiper = new Swiper('.Large', {
	direction: 'horizontal', // 垂直切换选项
	loop: true, // 循环模式选项

	// 如果需要分页器
	pagination: {
		el: '.swiper-pagination',
	},

	// 如果需要前进后退按钮
	navigation: {
		nextEl: '.swiper-button-next',
		prevEl: '.swiper-button-prev',
	},
	autoplay: {
		delay: 2000,
		stopOnLastSlide: false,
		disableOnInteraction: true,
	}
});
$("header").html(`
			<img src="img/logo.png" class="logoImg">
			<span class="logoText">财务与资产管理部</span>
`)
$(".topNav").html(`
<div onclick="goHref('index.html')">首页
			</div>
			<div>机构设置
				<div class="navMenu">
					<div>部门简介</div>
					<div>组织领导</div>
					<div onmouseover="console.log($(this).next().show())">科室设置</div>
					<div class="navMenuTwo" onmouseleave="console.log($(this).hide())">
					<div onmouseleave="console.log($(this).parent().hide())">
					<div>综合科</div>
					<div>财务管理科</div>
					<div>会计核算科</div>
					<div>支付中心</div>
					<div>代理记账科</div>
					<div>稽核科</div>
					<div>人员收费管理科</div>
					<div>大型精密仪器共享中心</div>
					<div>资产管理科</div>
					<div>招标采购科</div>
					<div>资产信息科</div>
					<div>校产管理科</div>
					<div>资产经营科</div>
					</div></div>
				</div>
			</div>
			<div>党务政务 <div class="navMenu">
				<!--
					<div onclick="goHref('list.html')">公告通知</div>
					<div onclick="goHref('list.html')">工作动态</div>
					<div onclick="goHref('list.html')">工作简报</div>
					-->
				</div>

			</div>
			<div>规章制度
				<div class="navMenu">
					<div>国家政策</div>
					<div>河南省政策</div>
					<div>学校政策</div>
				</div>
			</div>
			<div>业务指南 <div class="navMenu">
					<div>财务管理流程</div>
					<div>资产管理流程</div>
					<div>招标管理流程</div>
					<div>产业管理流程</div>
				</div>
			</div>
			<div>资料下载 <div class="navMenu">
					<div>财务资料下载</div>
					<div>资产资料下载</div>
					<div>招标资料下载</div>
					<div>产业资料下载</div>
				</div>
			</div>
			<div class="navLast">三</div>
`)

let Menu = false
$(".navLast").click(() => {
	$("nav div:not(div.navMenu):not(div.navLast)").each((index, item) => {
		!Menu ? item.style.display = "block" : item.style.display = "none"
	})
	Menu = !Menu
})

function goHref(url) {
	window.location.href = url
}

class VElement {
	constructor(tagName, props, children) {
		this.tagName = tagName
		this.props = props || {}
		this.children = children || []
		this.key = props ? props.key : undefined
		this.count = this.children.length
	}
	bindEl(to) {
		typeof to === "string" ? document.querySelector(to).appendChild(this.toHTML()) : to.appendChild(this
			.toHTML())
	}
	useEl(to) {

		if (typeof to === "string") {
			document.querySelector(to).innerHTML = "";
			document.querySelector(to).appendChild(this.toHTML())
		} else {
			to.innerHTML = "";
			to.appendChild(this
				.toHTML())
		}
	}
	toHTML() {
		let dom = document.createElement(this.tagName)
		for (let i in this.props) {
			dom[i] = this.props[i]
		}
		for (let cdom of this.children) {
			cdom = cdom.toHTML()
			dom.appendChild(cdom)
		}
		return dom
	}
	addChild(VDOM) {
		this.children.push(VDOM)
	}
	delChild(key) {
		this.children = this.children.filter((c) => {
			return c.key != key
		})
	}
	clear() {
		this.children = []
	}
}

function cTemplate(day, month, title, url) {
	return {
		day,
		month,
		title,
		url
	}
}


function createTypeSelect(type, content, to) {
	this.type = type
	this.content = content
	let littleNav = document.createElement("div")
	littleNav.className = "littleNav"
	let littleConent = document.createElement("div")
	let ul = document.createElement('ul')
	this.selectedNum = {
		n: 0
	}
	let proxyObj = new Proxy(this.selectedNum, {
		get: function(target, attr) {
			console.log("读取")
			return target[attr];
		},
		set: function(target, attr, value) {
			target[attr] = value;
			for (let i = 0; i < type.length; i++) {
				ul.childNodes[i].className = ""
				littleConent.childNodes[i].style.display = "none"
			}
			console.log(littleConent.childNodes[value])
			ul.childNodes[value].className = "selected"
			littleConent.childNodes[value].style.display = "block"
		}
	});
	for (let aType of type) {
		let li = document.createElement('li')
		li.innerHTML = aType
		let n = ul.children.length
		li.addEventListener("click", () => {
			proxyObj.n = n
		})
		n == 0 ? li.className = "selected" : null
		ul.appendChild(li)
	}

	littleNav.appendChild(ul)
	for (let cont of content) {
		let infoConent = document.createElement("div")
		infoConent.className = "infoConent"
		let n = littleConent.children.length
		infoConent.setAttribute("type", "message")
		for (let c of cont) {
			let outerDIv = document.createElement("div")
			let dateDiv = document.createElement("div")
			dateDiv.className = "date"
			let dayH = document.createElement("h2")
			dayH.innerText = c.day
			let monthH = document.createElement("h3")
			monthH.innerText = c.month
			dateDiv.appendChild(dayH)
			dateDiv.appendChild(monthH)
			let title = document.createElement("span")
			title.className = "messageTitle"
			title.innerText = c.title
			n == 0 ? null : infoConent.style.display = "none"

			outerDIv.addEventListener("click", () => {
				location.href = c.url
			})

			outerDIv.appendChild(dateDiv)
			outerDIv.appendChild(title)
			infoConent.appendChild(outerDIv)
		}
		littleConent.append(infoConent)
	}
	console.log(typeof to == "string")
	if (typeof to == "string") {
		document.querySelector(to).appendChild(littleNav)
		document.querySelector(to).appendChild(littleConent)
	} else {
		to.appendChild(littleNav)
		to.appendChild(littleConent)
	}
}

function createDefaultSelect(content, to) {
	this.content = content
	let littleConent = document.createElement("div")
	let ul = document.createElement('ul')
	for (let cont of content) {
		console.log(cont)
		let infoConent = document.createElement("div")
		infoConent.className = "infoConent"
		infoConent.setAttribute("type", "message")
		let outerDIv = document.createElement("div")
		let dateDiv = document.createElement("div")
		dateDiv.className = "date"
		let dayH = document.createElement("h2")
		dayH.innerText = cont.day
		let monthH = document.createElement("h3")
		monthH.innerText = cont.month
		dateDiv.appendChild(dayH)
		dateDiv.appendChild(monthH)
		let title = document.createElement("span")
		title.className = "messageTitle"
		title.innerText = cont.title

		outerDIv.addEventListener("click", () => {
			location.href = cont.url
		})
		outerDIv.appendChild(dateDiv)
		outerDIv.appendChild(title)
		infoConent.appendChild(outerDIv)

		littleConent.append(infoConent)
	}
	console.log(typeof to == "string")
	if (typeof to == "string") {
		document.querySelector(to).appendChild(littleConent)
	} else {
		to.appendChild(littleConent)
	}

}
document.querySelector("footer").innerHTML = `<div class="logo"><img src="img/logo.png" class="logoImg">
				<span class="logoText">财务与资产管理部</span>
			</div>
			<div align="center" style="padding:20px">
				版权所有  2023河南科技大学 | 河南科技大学财务与资产管理部 主办 | <a href="http://finance.haust.edu.cn/" class="whiteA">综合财务查询（旧版）</a><br>
			</div>`
